<script setup>
import { ref } from 'vue'

const currentPage = ref(1)
const pageSize = ref(10)
const total = ref(0)

const emits = defineEmits(['size-change', 'current-change'])

const handleSizeChange = (val) => {
  currentPage.value = 1
  emits('size-change', val)
}

const handleCurrentChange = (val) => {
  emits('current-change', val)
}

defineExpose({
  currentPage,
  pageSize,
  total
})
</script>

<template>
  <div class="demo-pagination-block">
    <el-pagination
      v-model:current-page="currentPage"
      v-model:page-size="pageSize"
      :page-sizes="[5, 10, 20, 30]"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>